//
//  UIView+KModuleUI.h
//  MengLiao
//
//  Created by xiuxin on 2022/7/15.
//  Copyright © 2022 ZHBen. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "KDDReuseView.h"
#import <Masonry/Masonry.h>

@protocol KMView <KDDReuseView>
+ (NSString *)viewID;
@optional
@property (weak,nonatomic) id kmDelegate;
//多规格配置
+ (NSString *)specForModel:(__kindof NSObject *)model;
//itemSize配置
+ (CGSize)sizeForSpec:(NSString *)spec model:(__kindof NSObject *)model;
//是否使用约束 默认为YES
- (BOOL)useLayout;
//初始化 规格信息
- (instancetype)initWithFrame:(CGRect)frame spec:(NSString *)spec;
//加载数据 位置信息
- (void)kmLoadModel:(__kindof NSObject *)model position:(KDDPosition *)position;

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes;

@end

@protocol KMDecorationView <KMView>
@optional
//边距配置
+ (UIEdgeInsets)insetsForSpec:(NSString *)spec;
//zIndex配置
+ (NSInteger)zIndexForSpec:(NSString *)spec;
//数据、开始位置信息
- (void)kmLoadModelList:(NSArray<__kindof NSObject *> *)modelList position:(KDDPosition *)position;

@end

@protocol KMWrapperView <NSObject>

@property (weak,nonatomic) __kindof UIView<KMView> * kmView;

@property (strong,nonatomic) UICollectionViewLayoutAttributes * attributes;

@property (nonatomic, readonly, strong) UIView * contentView;

@end

@interface UIView (KModuleUI)<KMView>

+ (UIView<KMView> *)addToWrapper:(UIView<KMWrapperView> *)wrapperView frame:(CGRect)frame spec:(NSString *)spec;

- (NSArray<MASConstraint *> *)kmLayoutList;

@end

@interface KModuleView : UIView
//规格信息
@property (readonly,copy,nonatomic) NSString * spec;

- (instancetype)initWithFrame:(CGRect)frame spec:(NSString *)spec;

@end

